import { Button } from 'antd';
import { ColumnProps } from 'antd/lib/table';
import React from 'react';
import moment from 'moment';
import { initTabWidth } from '@/pages/finance/withdraw/utils';
// import {checkPermission} from '@/utils/resolvePermission';

interface StateType {
  [propName: string]: any;
}

export const getColumns = (self: any) => {
  const platformStateMap = {
    0: '未处理',
    1: '待回复',
    2: '待发送',
    3: '已回复',
  };
  const userStateMap = {
    0: '未读',
    1: '已读',
  };

  const columns: ColumnProps<StateType>[] = [
    {
      title: '类别',
      dataIndex: 'typeName',
    },
    {
      title: '标题',
      dataIndex: 'title',
    },
    {
      title: '收件时间',
      dataIndex: 'receiptTime',
      render: time => time && <span>{moment(time).format('YY-MM-DD HH:mm:ss')}</span>,
    },
    {
      title: '会员帐号',
      dataIndex: 'userName',
    },
    {
      title: '回复人',
      dataIndex: 'replyName',
    },
    {
      title: '状态',
      dataIndex: 'platformState',
      render: key => <span>{platformStateMap[key]}</span>,
    },
    {
      title: '会员是否已读',
      dataIndex: 'userState',
      render: key => <span>{userStateMap[key]}</span>,
    },
    {
      title: '操作',
      // width: 130,
      fixed: 'right',
      render: (text: any, rowData: any) => (
        <Button
          type="link"
          onClick={() => {
            self.showCheckModal(rowData);
          }}
        >
          查看
        </Button>
      ),
    },
  ];
  initTabWidth(columns, 196);
  return columns;
};
